package top.raxidin.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.raxidin.common.interceptor.LoginIntreceptor;

@Configuration
public class MyWebConfig implements WebMvcConfigurer {



    @Autowired
    private LoginIntreceptor loginIntreceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        WebMvcConfigurer.super.addInterceptors(registry);

        InterceptorRegistration interceptorRegistration = registry.addInterceptor(loginIntreceptor);

        //拦截请求

        interceptorRegistration.addPathPatterns("/**");

        //放行请求

        interceptorRegistration.excludePathPatterns(
                "/user/login",
                "user/logout",
                "/layui/**",
                "/js/**",
                "/login",
                "/captcha",
                "/lib/**"
        );


    }
}
